﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Vehicle.Web.Pages.Cargo
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Cargo_Add.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-09-01   Created by 杨光远 V1.00.0000
    /// 功能说明：承运单添加页面类
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Cargo_Add :Component.PageBase
    {
        #region---基本变量实例化---
        BLL.Cargo b_Cargo = new Vehicle.BLL.Cargo();
        BLL.Log b_Log = new Vehicle.BLL.Log();
        Model.CargoInfo m_CargoInfo = new Vehicle.Model.CargoInfo();
        #endregion

        #region---基本操作---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }

        }
        /// <summary>
        /// 添加事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Add_Click1(object sender, EventArgs e)
        {  
            //添加前判断是否已经有该编号的承运单
            if (b_Cargo.GetModel(new Vehicle.Model.ComponentsInfo("Cargo", "C_Card", txt_C_Card.Text.Trim(), "1", "1", "C_IsDelete", "1", "C_ID")).Rows.Count == 0)
            {
                m_CargoInfo.C_Card = txt_C_Card.Text.Trim();//承运单编号
                m_CargoInfo.C_weight =Common.TextHelper.StringTofloat(txt_C_weight.Text.Trim());//货物重量
                m_CargoInfo.C_Route = txt_C_Route.Text.Trim();//承运路线
                m_CargoInfo.C_Addresss = txt_C_Addresss.Text.Trim();//货物承运地址
                m_CargoInfo.C_contract = txt_C_contract.Text.Trim();//合同号
                m_CargoInfo.C_GoodsName = txt_C_GoodsName.Text.Trim();//货物名称
                m_CargoInfo.C_LoadAddr = txt_C_LoadAddr.Text.Trim();//货物装车地址
                m_CargoInfo.C_CTime = Common.TextHelper.StringToDateTime(Gmdp_C_CTime.DateString);//货物装车时间
                m_CargoInfo.C_StartTime = Common.TextHelper.StringToDateTime(Gmdp_C_StartTime.DateString);//要求起始时间
                m_CargoInfo.C_EndTime = Common.TextHelper.StringToDateTime(Gmdp_C_EndTime.DateString);//要求结束时间
                m_CargoInfo.C_Receive = 3;//是否被接收    1是 2否  3审核 
                m_CargoInfo.C_Result =4;//运输结果     	1运输中 2已完成 3失败 4审核
                m_CargoInfo.C_Time = DateTime.Now;//添加时间
                m_CargoInfo.C_AddName =b_Cargo.GetModel(new Vehicle.Model.ComponentsInfo ("Admin","A_ID",session_ID.ToString(),"A_ID")).Rows[0]["A_Name"].ToString() ;//读Session
                m_CargoInfo.C_LastTime = DateTime.Now;//最后更新时间 默认为当前时间
                m_CargoInfo.C_Fax = txt_C_Fax.Text.Trim(); //传真号码
                m_CargoInfo.C_Tel = txt_C_Tel.Text.Trim();//电话号码
                m_CargoInfo.C_CAddress=txt_C_CAddress.Text.Trim();//客户公司联系地址
                m_CargoInfo.C_CName = txt_C_CName.Text.Trim();//客户公司名称
                m_CargoInfo.C_Contact = txt_C_Contact.Text.Trim();//客户姓名
                m_CargoInfo.C_Mobilephone = txt_C_Mobilephone.Text.Trim();//客户移动电话
                m_CargoInfo.C_HomePhone=txt_C_HomePhone.Text.Trim();//客户家庭电话
                m_CargoInfo.C_Note = Common.TextHelper.CheckStr(txt_C_Note.Text);//承运单备注
                m_CargoInfo.C_IsDelete = 0;//是否删除
                m_CargoInfo.C_Sendee = txt_C_Sendee.Text.Trim();//接收人姓名
                m_CargoInfo.C_STel = txt_C_STel.Text.Trim();//接收人地址
                m_CargoInfo.C_Money =Common.TextHelper.StringTofloat( txt_C_Money.Text.Trim());//承运金额
                b_Cargo.Add(m_CargoInfo);
                b_Log.Add(new Vehicle.Model.LogInfo(session_ID, DateTime.Now, "成功添加编号为" + txt_C_Card.Text.Trim() + "的承运单"));//添加日志
                Common.MessageHelper.AlertRedirect("承运单信息添加成功", "Main.aspx");
            }
            else
            {
                Common.MessageHelper.Alert("已经有相同编号的承运单,请重新填写");
            }
        }
        #endregion
    }
}
